{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.  不同的命名空间。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "foo/bar:0\n",
      "bar/bar:0\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "with tf.variable_scope(\"foo\"):\n",
    "    a = tf.get_variable(\"bar\", [1])\n",
    "    print(a.name)\n",
    "\n",
    "with tf.variable_scope(\"bar\"):\n",
    "    b = tf.get_variable(\"bar\", [1])\n",
    "    print(b.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2. tf.Variable和tf.get_variable的区别。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a/Variable:0\n",
      "b:0\n"
     ]
    }
   ],
   "source": [
    "with tf.name_scope(\"a\"):\n",
    "    a = tf.Variable([1])\n",
    "    print(a.name)\n",
    "    \n",
    "    a = tf.get_variable(\"b\", [1])\n",
    "    print(a.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3. TensorBoard可以根据命名空间来整理可视化效果图上的节点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "with tf.name_scope(\"input1\"):\n",
    "    input1 = tf.constant([1.0, 2.0, 3.0], name=\"input2\")\n",
    "with tf.name_scope(\"input2\"):\n",
    "    input2 = tf.Variable(tf.random_uniform([3]), name=\"input2\")\n",
    "output = tf.add_n([input1, input2], name=\"add\")\n",
    "\n",
    "writer = tf.summary.FileWriter(\"log/simple_example.log\", tf.get_default_graph())\n",
    "writer.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
